package com.leyou.item.controller;

import com.leyou.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ItemController {
    @Autowired
    private ItemService itemService;

    @RequestMapping("/save")
    public ResponseEntity<Long> saveItem(@RequestParam("id") Long id){
        /**
         * status():设置状态响应码
         * body():设置响应体
         */
        // 添加成功使用CREATED,查询成功使用OK,修改和删除成功使用NO_CONTENT
        return ResponseEntity.status(HttpStatus.CREATED).body(itemService.saveItem(id));
    }
}
